package com.xugou.service.Impl;

import com.xugou.dao.NoticeDao;
import com.xugou.pojo.Notice;
import com.xugou.service.NoticeService;

import java.util.List;

/**
 * @author xugou
 * @date 2022/6/13  15:24
 */
public class NoticeServiceImpl implements NoticeService {

    private NoticeDao noticeDao;

    public void setNoticeDao(NoticeDao noticeDao) {
        this.noticeDao = noticeDao;
    }

    public List<Notice> getNoticeList() {
        List<Notice> noticeList = noticeDao.getNoticeList();
        if (noticeList==null){
            return null;
        }
        return noticeList;
    }

    public Notice getNoticeById(int id) {
        Notice notice = noticeDao.getNoticeById(id);
        if (notice==null){
            return null;
        }
        return notice;
    }

    public boolean addNotice(Notice notice) {
        int i = noticeDao.addNotice(notice);
        if (i!=1){
            return false;
        }else {
            return true;
        }
    }

    public boolean deleteNotice(int id) {
        int i = noticeDao.deleteNotice(id);
        if (i!=1){
            return false;
        }else {
            return true;
        }
    }

    public boolean updateNotice(Notice notice) {
        int i = noticeDao.updateNoticeById(notice);
        if (i!=1){
            return false;
        }else {
            return true;
        }
    }
}
